package autotd;

import java.awt.Point;

public class Unit {
	public static final int TICK_DELAY = 120;
	public static final Point DEFAULT_POINT = new Point(-1,-1);

	public int id;
	public int delay;
	public int timer;
	public Point pos;
	
	public Unit(int d) {
		delay = d;
		timer = 0;
		pos = DEFAULT_POINT;
	}

	public void tick() {
		timer = Math.max(timer - TICK_DELAY, 0);
	}
	
	public boolean ready() {
		return timer < TICK_DELAY;
	}
	
	public boolean act() {
		if (!ready()) {
			return false;
		}
		timer += delay;
		return true;
	}
	
	
	public int hashCode() {
		return id;
	}
}












